package cn.com.cym.gamezao.web.demo;

import cn.com.cym.gamezao.annotation.AuthToken;
import cn.com.cym.gamezao.base.BaseController;
import cn.com.cym.gamezao.base.BaseService;
import cn.com.cym.gamezao.entity.demo.Father;
import cn.com.cym.gamezao.service.demo.FatherService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Api(tags = "x-oneByOne父类控制类")
@RestController
@RequestMapping(value = "father")
@AuthToken(require = false, rule = "")
public class FatherController extends BaseController<Father> {

    final FatherService thisService;

    public FatherController(FatherService fatherService){
        this.thisService=fatherService;
    }

    @Override
    public BaseService<Father> getService() {
        return this.thisService;
    }


    @ApiImplicitParam(name = "father", value = "father", required = true,dataType = "Father")
    @ApiOperation(value = "新建父类数据")
    @ApiOperationSupport(order = 3, author = "mr.chen")
    @PostMapping()
    public ResponseEntity<?> add(@RequestBody Father father){
        final Father storeFather = this.thisService.save(father);
        return ResponseEntity.ok(storeFather);
    }


    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id",paramType = "path", required = true,dataType = "Long"),
            @ApiImplicitParam(name = "father", value = "father",paramType = "", required = true,dataType = "Father")})
    @ApiOperation(value = "修改父类数据")
    @ApiOperationSupport(order = 4, author = "mr.chen")
    @PutMapping("/{id}")
    public ResponseEntity<?> update(@RequestBody Father father,@PathVariable Long id){
        final Father storeFather = this.thisService.update(father,id);
        return ResponseEntity.ok(storeFather);
    }
}
